JTextField.getText()
A JTextField
holds the text that the user entered.
Get that text using the getText()
method.
You must then convert the text into a numeric type, like int
.
The parseInt()
method of the wrapper class Integer
can do this.
It is a static method, so you do not need to construct an object to use it.
Here is the program so far. To finish it fill in the remaining blanks.
getText()
method to get the user's input.parseInt()
static method of the wrapper class Integer
to
convert the input to an int
.setText()
method to convert and display the result in outCel
.What is going on with:
outCel.setText( celsTemp+"" );